home *** CD-ROM | disk | FTP | other *** search
/ Amiga Game-Power / Amiga Game-Power.iso / pd mix ii / access / thai / assigned.c < prev    next >
C/C++ Source or Header  |  1994-05-20  |  1KB  |  63 lines

  1. /* Modified from fish 66 */
  2.  
  3. #include <stdio.h>
  4. #include <exec/types.h>
  5. #include <libraries/dosextens.h>
  6.  
  7. extern APTR OpenLibrary ();
  8.  
  9. #define    AS_UNKNOWN    0
  10. #define    AS_DEVICE    1
  11. #define    AS_DIR        2
  12. #define    AS_DRIVE    3
  13.  
  14. int
  15. Assigned(searchname)
  16. char    *searchname;
  17. {
  18.     struct    DosLibrary    *DosLibrary;
  19.     struct    RootNode    *RootNode;
  20.     struct    DosInfo        *DosInfo;
  21.     struct    DeviceList    *DevInfo;
  22.     char    name[256];
  23.     char    *astr;
  24.     BSTR    bstr;
  25.     long    type;
  26.     int    i,rc;
  27.  
  28.     DosLibrary = (struct DosLibrary *)OpenLibrary("dos.library",0);
  29.     RootNode = (struct RootNode *)DosLibrary->dl_Root;
  30.     DosInfo = (struct DosInfo *)BADDR(RootNode->rn_Info);
  31.     DevInfo = (struct DeviceList *)BADDR(DosInfo->di_DevInfo);
  32.  
  33.     rc = AS_UNKNOWN;
  34.     while (DevInfo != NULL) {
  35.         type = DevInfo->dl_Type;
  36.         bstr = (BSTR)DevInfo->dl_Name;
  37.         astr = (char *)BADDR(bstr);
  38.         for (i = 0; i < astr[0]; i++)
  39.             name[i] = astr[i+1];
  40.         name[i] = '\0';
  41.         if (strsame(name,searchname)) {
  42.             rc = type;
  43.             DevInfo = NULL;
  44.         }
  45.         else
  46.             DevInfo = (struct DeviceList *)BADDR(DevInfo->dl_Next);
  47.     }
  48.     CloseLibrary(DosLibrary);
  49.     return(rc);
  50. }
  51.  
  52.  
  53. static int
  54. strsame ( s1 , s2 )
  55. register char *s1 , *s2;
  56. {
  57.     while ( *s1 != '\0' ) {
  58.         if ( mklower ( *s1++ ) != mklower ( *s2++ ) )
  59.             return ( FALSE );
  60.     }
  61.     return ( *s2 == '\0' );
  62. }
  63.